/*
 数组
 */

import Cocoa

//创建一个名为bucketList的数组类型的变量《方法1》
var bucketList1:Array<String> = ["init1"]

//创建一个名为bucketList的数组类型的变量《方法2》
var bucketList2:[String] = ["init2"]

//创建一个名为bucketList的数组类型的变量《方法3》
var bucketList3 = ["init3"]


//2.访问和修改数组
bucketList1.append("newObject")
bucketList2.append("newObject")
bucketList2.remove(at: 1)
print(bucketList1.count)
print(bucketList1[0...1])

bucketList3[0] += "addText"
print(bucketList3)

bucketList3[0] = "replace"
print(bucketList3)

bucketList3 += bucketList2
bucketList3.insert("insert", at: 2)

//两个数组要内容和顺序完全一样才会相等
var leftArr:Array<String> = ["1","2"]
var rightArr1 = ["1","2"]
var rightArr2:[String] = ["2","1"]

let equal = leftArr == rightArr1
let equal1 = leftArr == rightArr2

//3.不可变数组
let lunches = ["1","2"]
